<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="设备名称">
              <a-input placeholder="请输入设备名称" v-model="queryParam.deviceId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END --> 

    <!-- table区域-begin -->
    <div>  
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading" 
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>

        <!--  <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
          !-->
        </span>

      </a-table>
    </div>

    <weather-data-modal ref="modalForm" @ok="modalFormOk"></weather-data-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import WeatherDataModal from './modules/WeatherDataModal'

  export default {
    name: 'WeatherDataList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      WeatherDataModal
    },
    data () {
      return {
        description: '天气数据管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            fixed:"left",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'设备名称',
            align:"center",
            dataIndex: 'deviceId_dictText',
            fixed:"left",
          },
          {
            title:'最小风速(m/s)',
            align:"center",
            dataIndex: 'minwspeed'
          },
          {
            title:'平均风速(m/s)',
            align:"center",
            dataIndex: 'avlwspeed'
          },
          {
            title:'最大风速(m/s)',
            align:"center",
            dataIndex: 'maxwspeed'
          },
          {
            title:'最小风向(度)',
            align:"center",
            dataIndex: 'minwdir'
          },
          {
            title:'平均风向(度)',
            align:"center",
            dataIndex: 'avlwdir'
          },
          {
            title:'最大风向(度)',
            align:"center",
            dataIndex: 'maxwdir'
          },
          {
            title:'雨量(mm)',
            align:"center",
            dataIndex: 'rains'
          },
          {
            title:'气压(hPa)',
            align:"center",
            dataIndex: 'airkpas'
          },
          {
            title:'辐射量(W/M2)',
            align:"center",
            dataIndex: 'radiation'
          },
          {
            title:'紫外线强度等级(UVI)',
            align:"center",
            dataIndex: 'ultraviolet'
          },
          {
            title:'单位dB',
            align:"center",
            dataIndex: 'noises'
          },
          {
            title:'pm25值(0.1 ug/m3)',
            align:"center",
            dataIndex: 'pm25s'
          },
          {
            title:'pm10值(0.1 ug/m3)',
            align:"center",
            dataIndex: 'pm1s'
          },
          {
            title:'测量温度',
            align:"center",
            dataIndex: 'mtemps'
          },
          {
            title:'测量湿度(%RH)',
            align:"center",
            dataIndex: 'mhumis'
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/corp/weatherData/list",
          delete: "/corp/weatherData/delete",
          deleteBatch: "/corp/weatherData/deleteBatch",
          exportXlsUrl: "/corp/weatherData/exportXls",
          importExcelUrl: "/corp/weatherData/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'deviceId',text:'设备id',dictCode:''})
        fieldList.push({type:'string',value:'minwspeed',text:'最小风速，m/s',dictCode:''})
        fieldList.push({type:'string',value:'avlwspeed',text:'平均风速，m/s ',dictCode:''})
        fieldList.push({type:'string',value:'maxwspeed',text:'最大风速，m/s ',dictCode:''})
        fieldList.push({type:'string',value:'minwdir',text:'最小风向，度 ',dictCode:''})
        fieldList.push({type:'string',value:'avlwdir',text:'平均风向，度',dictCode:''})
        fieldList.push({type:'string',value:'maxwdir',text:'最大风向，度 ',dictCode:''})
        fieldList.push({type:'string',value:'rains',text:'雨量，单位mm ',dictCode:''})
        fieldList.push({type:'string',value:'airkpas',text:'气压，单位hPa',dictCode:''})
        fieldList.push({type:'string',value:'radiation',text:'辐射量，单位 W/M2',dictCode:''})
        fieldList.push({type:'string',value:'ultraviolet',text:'紫外线强度等级，单位UVI',dictCode:''})
        fieldList.push({type:'string',value:'noises',text:'单位dB',dictCode:''})
        fieldList.push({type:'string',value:'pm25s',text:'pm25值, 0.1 ug/m3',dictCode:''})
        fieldList.push({type:'string',value:'pm1s',text:'pm10值, 0.1 ug/m3',dictCode:''})
        fieldList.push({type:'string',value:'mtemps',text:'测量温度',dictCode:''})
        fieldList.push({type:'string',value:'mhumis',text:'测量湿度，单位 %RH',dictCode:''})
        fieldList.push({type:'date',value:'tmstamp',text:'时间戳'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>